<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>HTTP 相关知识科普 | Guru Note</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="stylesheet" href="./font/index.css">
    <script src="/docs/icon/svg.js"></script>
    <meta name="description" content="Sea of dawn">
    
    <link rel="preload" href="/docs/assets/css/0.styles.efa081cd.css" as="style"><link rel="preload" href="/docs/assets/js/app.cdec4db9.js" as="script"><link rel="preload" href="/docs/assets/js/2.993bd611.js" as="script"><link rel="preload" href="/docs/assets/js/32.2dad91d1.js" as="script"><link rel="preload" href="/docs/assets/js/7.5a12abef.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.c3177bdb.js"><link rel="prefetch" href="/docs/assets/js/100.60c23478.js"><link rel="prefetch" href="/docs/assets/js/101.7ea29e1b.js"><link rel="prefetch" href="/docs/assets/js/102.7f47e485.js"><link rel="prefetch" href="/docs/assets/js/103.ea9ce400.js"><link rel="prefetch" href="/docs/assets/js/104.4ec6a518.js"><link rel="prefetch" href="/docs/assets/js/105.75526347.js"><link rel="prefetch" href="/docs/assets/js/106.01f6b03b.js"><link rel="prefetch" href="/docs/assets/js/107.69fe0811.js"><link rel="prefetch" href="/docs/assets/js/108.fa23768b.js"><link rel="prefetch" href="/docs/assets/js/109.90df1698.js"><link rel="prefetch" href="/docs/assets/js/11.54347528.js"><link rel="prefetch" href="/docs/assets/js/110.dd8d7227.js"><link rel="prefetch" href="/docs/assets/js/111.ccf25ceb.js"><link rel="prefetch" href="/docs/assets/js/112.6963298f.js"><link rel="prefetch" href="/docs/assets/js/113.30ceb3d8.js"><link rel="prefetch" href="/docs/assets/js/114.42ef6603.js"><link rel="prefetch" href="/docs/assets/js/115.f1db7817.js"><link rel="prefetch" href="/docs/assets/js/116.92971223.js"><link rel="prefetch" href="/docs/assets/js/117.c5a65e7e.js"><link rel="prefetch" href="/docs/assets/js/118.e329035d.js"><link rel="prefetch" href="/docs/assets/js/119.cbb17c5e.js"><link rel="prefetch" href="/docs/assets/js/12.c8144ee8.js"><link rel="prefetch" href="/docs/assets/js/120.8537f6a6.js"><link rel="prefetch" href="/docs/assets/js/121.257d3851.js"><link rel="prefetch" href="/docs/assets/js/122.96a5f921.js"><link rel="prefetch" href="/docs/assets/js/123.2220fd12.js"><link rel="prefetch" href="/docs/assets/js/124.552b1a29.js"><link rel="prefetch" href="/docs/assets/js/125.4e36fe37.js"><link rel="prefetch" href="/docs/assets/js/126.3939cdcc.js"><link rel="prefetch" href="/docs/assets/js/127.014df434.js"><link rel="prefetch" href="/docs/assets/js/13.edc237a8.js"><link rel="prefetch" href="/docs/assets/js/14.66270d4f.js"><link rel="prefetch" href="/docs/assets/js/15.0804164b.js"><link rel="prefetch" href="/docs/assets/js/16.dec928ab.js"><link rel="prefetch" href="/docs/assets/js/17.bbfc90a8.js"><link rel="prefetch" href="/docs/assets/js/18.76904860.js"><link rel="prefetch" href="/docs/assets/js/19.80a98011.js"><link rel="prefetch" href="/docs/assets/js/20.c39e42bd.js"><link rel="prefetch" href="/docs/assets/js/21.287b744a.js"><link rel="prefetch" href="/docs/assets/js/22.c9506be7.js"><link rel="prefetch" href="/docs/assets/js/23.9732a229.js"><link rel="prefetch" href="/docs/assets/js/24.21ed1f05.js"><link rel="prefetch" href="/docs/assets/js/25.8f1926f6.js"><link rel="prefetch" href="/docs/assets/js/26.61b6eb9f.js"><link rel="prefetch" href="/docs/assets/js/27.3706753c.js"><link rel="prefetch" href="/docs/assets/js/28.b6b182cf.js"><link rel="prefetch" href="/docs/assets/js/29.ae979ad9.js"><link rel="prefetch" href="/docs/assets/js/3.a7f8dd77.js"><link rel="prefetch" href="/docs/assets/js/30.f2233269.js"><link rel="prefetch" href="/docs/assets/js/31.06780314.js"><link rel="prefetch" href="/docs/assets/js/33.87ec6e22.js"><link rel="prefetch" href="/docs/assets/js/34.7b75f220.js"><link rel="prefetch" href="/docs/assets/js/35.3184991f.js"><link rel="prefetch" href="/docs/assets/js/36.28248fbe.js"><link rel="prefetch" href="/docs/assets/js/37.5824a979.js"><link rel="prefetch" href="/docs/assets/js/38.99a364fe.js"><link rel="prefetch" href="/docs/assets/js/39.a5f43732.js"><link rel="prefetch" href="/docs/assets/js/4.a55d89ed.js"><link rel="prefetch" href="/docs/assets/js/40.629f78f7.js"><link rel="prefetch" href="/docs/assets/js/41.e4f58d1c.js"><link rel="prefetch" href="/docs/assets/js/42.9f41aa47.js"><link rel="prefetch" href="/docs/assets/js/43.636412b6.js"><link rel="prefetch" href="/docs/assets/js/44.3b491aef.js"><link rel="prefetch" href="/docs/assets/js/45.77df19bc.js"><link rel="prefetch" href="/docs/assets/js/46.01f53ddd.js"><link rel="prefetch" href="/docs/assets/js/47.476e85c9.js"><link rel="prefetch" href="/docs/assets/js/48.198502dc.js"><link rel="prefetch" href="/docs/assets/js/49.0d59d332.js"><link rel="prefetch" href="/docs/assets/js/5.1597c0f8.js"><link rel="prefetch" href="/docs/assets/js/50.02baf101.js"><link rel="prefetch" href="/docs/assets/js/51.c9fbd54d.js"><link rel="prefetch" href="/docs/assets/js/52.4cb4459b.js"><link rel="prefetch" href="/docs/assets/js/53.248450d7.js"><link rel="prefetch" href="/docs/assets/js/54.83f12d1e.js"><link rel="prefetch" href="/docs/assets/js/55.b18accba.js"><link rel="prefetch" href="/docs/assets/js/56.8a160b09.js"><link rel="prefetch" href="/docs/assets/js/57.b854a940.js"><link rel="prefetch" href="/docs/assets/js/58.4500f315.js"><link rel="prefetch" href="/docs/assets/js/59.59400e36.js"><link rel="prefetch" href="/docs/assets/js/6.887ba020.js"><link rel="prefetch" href="/docs/assets/js/60.4dd5b5bb.js"><link rel="prefetch" href="/docs/assets/js/61.50d8c8f6.js"><link rel="prefetch" href="/docs/assets/js/62.17d10daa.js"><link rel="prefetch" href="/docs/assets/js/63.d5f821cc.js"><link rel="prefetch" href="/docs/assets/js/64.7bf2519f.js"><link rel="prefetch" href="/docs/assets/js/65.0a1c9bc8.js"><link rel="prefetch" href="/docs/assets/js/66.1bcaa81c.js"><link rel="prefetch" href="/docs/assets/js/67.326bdf9b.js"><link rel="prefetch" href="/docs/assets/js/68.2b3b63b2.js"><link rel="prefetch" href="/docs/assets/js/69.c9b1a1a9.js"><link rel="prefetch" href="/docs/assets/js/70.a5fede78.js"><link rel="prefetch" href="/docs/assets/js/71.288d9643.js"><link rel="prefetch" href="/docs/assets/js/72.8665d6b8.js"><link rel="prefetch" href="/docs/assets/js/73.47155429.js"><link rel="prefetch" href="/docs/assets/js/74.4d4738f8.js"><link rel="prefetch" href="/docs/assets/js/75.659a325f.js"><link rel="prefetch" href="/docs/assets/js/76.a263f692.js"><link rel="prefetch" href="/docs/assets/js/77.9d86d59e.js"><link rel="prefetch" href="/docs/assets/js/78.a41b5d88.js"><link rel="prefetch" href="/docs/assets/js/79.5d0fc4cc.js"><link rel="prefetch" href="/docs/assets/js/8.80d0c81d.js"><link rel="prefetch" href="/docs/assets/js/80.01a11f6a.js"><link rel="prefetch" href="/docs/assets/js/81.9c0207d9.js"><link rel="prefetch" href="/docs/assets/js/82.12be8e04.js"><link rel="prefetch" href="/docs/assets/js/83.00fa5f46.js"><link rel="prefetch" href="/docs/assets/js/84.f14cd53c.js"><link rel="prefetch" href="/docs/assets/js/85.e9d7c0d1.js"><link rel="prefetch" href="/docs/assets/js/86.eb78fbbf.js"><link rel="prefetch" href="/docs/assets/js/87.8a31f5ae.js"><link rel="prefetch" href="/docs/assets/js/88.0f10e6dc.js"><link rel="prefetch" href="/docs/assets/js/89.a17253c9.js"><link rel="prefetch" href="/docs/assets/js/9.2fa568cb.js"><link rel="prefetch" href="/docs/assets/js/90.e56bc609.js"><link rel="prefetch" href="/docs/assets/js/91.5277db18.js"><link rel="prefetch" href="/docs/assets/js/92.b0bb8aa7.js"><link rel="prefetch" href="/docs/assets/js/93.cd790b77.js"><link rel="prefetch" href="/docs/assets/js/94.76bbe227.js"><link rel="prefetch" href="/docs/assets/js/95.4f07ca32.js"><link rel="prefetch" href="/docs/assets/js/96.2b1e8485.js"><link rel="prefetch" href="/docs/assets/js/97.e93b3461.js"><link rel="prefetch" href="/docs/assets/js/98.658063a1.js"><link rel="prefetch" href="/docs/assets/js/99.a3642e6d.js">
    <link rel="stylesheet" href="/docs/assets/css/0.styles.efa081cd.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">Guru Note</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----> <svg aria-hidden="true" class="icon search-icon"><use xlink:href="#icon-search"></use></svg></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><div class="el-scrollbar"><div class="scrollbar-wrapper el-scrollbar__wrap el-scrollbar__wrap--hidden-default"><div class="el-scrollbar__view"><nav class="nav-links"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/docs/devbook/" aria-current="page" class="sidebar-link">介绍</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>开发者小记</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/note/regex-getting-started.html" class="sidebar-link">正则表达式入门</a></li><li><a href="/docs/devbook/note/lisp-getting-started.html" class="sidebar-link">Lisp 入门</a></li><li><a href="/docs/devbook/note/search-skill.html" class="sidebar-link">搜索引擎常用技巧</a></li><li><a href="/docs/devbook/note/the-http.html" aria-current="page" class="active sidebar-link">HTTP 相关知识科普</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>环境搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/setting/node-use.html" class="sidebar-link">Node.js 安装教程</a></li><li><a href="/docs/devbook/setting/cmder-install.html" class="sidebar-link">Cmder 配置教程</a></li><li><a href="/docs/devbook/setting/vscode-and-cmder-use.html" class="sidebar-link">VSCode 与 Cmder 配合使用</a></li><li><a href="/docs/devbook/setting/tool-recommend.html" class="sidebar-link">Windows 常用工具</a></li><li><a href="/docs/devbook/setting/webstorm.html" class="sidebar-link">WebStorm 配置</a></li><li><a href="/docs/devbook/setting/vscode.html" class="sidebar-link">VSCode 配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>命令行工具</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/cli-plugin.html" class="sidebar-link">命令行常用插件</a></li><li><a href="/docs/devbook/cli-hot-key.html" class="sidebar-link">命令行快捷键</a></li><li><a href="/docs/devbook/git-getting-started.html" class="sidebar-link">Git 命令入门</a></li><li><a href="/docs/devbook/git-many-remotely.html" class="sidebar-link">Git 关联多个远程仓库</a></li><li><a href="/docs/devbook/mobile-file.html" class="sidebar-link">文件操作命令</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>博客搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/hexo-build-blog.html" class="sidebar-link">Hexo 搭建博客教程</a></li><li><a href="/docs/devbook/hexo-generate.html" class="sidebar-link">Hexo 生成永久链接</a></li><li><a href="/docs/devbook/hexo-theme.html" class="sidebar-link">Hexo 主题推荐</a></li><li><a href="/docs/devbook/hugo-created-blog.html" class="sidebar-link">Hugo 搭建个人博客</a></li></ul></section></li></ul> </div></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="width:0;transform:translateX(0%);ms-transform:translateX(0%);webkit-transform:translateX(0%);"></div></div><div class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height:0;transform:translateY(0%);ms-transform:translateY(0%);webkit-transform:translateY(0%);"></div></div></div></aside> <main class="page"> <div class="re-page-top"><h1 class="title"><span>HTTP 相关知识科普</span></h1> <div class="re-page-index"><div class="page-index-title"><span class="open-catalog"><svg aria-hidden="true" class="icon arrow-right"><use xlink:href="#icon-bold-right"></use></svg> <span class="text">目录</span></span></div> <div class="page-index-content"><div class="page-catalog" style="display:none;"><div class="synopsis-wrap"><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#www-的历史" class="synopsis-link">WWW 的历史</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#curl-命令" class="synopsis-link">curl 命令</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#markdown" class="synopsis-link">Markdown</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#www-的发明" class="synopsis-link">WWW 的发明</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#uri是什么" class="synopsis-link">URI是什么</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#urn" class="synopsis-link">URN</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#url" class="synopsis-link">URL</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#dns" class="synopsis-link">DNS</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#指定ip" class="synopsis-link">指定IP</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#server-client-http" class="synopsis-link">Server + Client + HTTP</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#常用端口" class="synopsis-link">常用端口</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#http" class="synopsis-link">HTTP</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#explainshell-com-网站" class="synopsis-link">explainshell.com 网站</a></li><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#请求" class="synopsis-link">请求</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/note/the-http.html#post请求" class="synopsis-link">POST请求</a></li></ul></li></ul></div></div></div></div></div> <div class="theme-default-content content__default"><h2 id="www-的历史"><a href="#www-的历史" class="header-anchor">#</a> WWW 的历史</h2> <p>1990年 万维网（World Wide Web）出生的年份。这一年 Tim Berners-Lee 发明了用网址就能访问网页的办法，他发明了第一个网页、第一个浏览器和第一个服务器。</p> <h2 id="curl-命令"><a href="#curl-命令" class="header-anchor">#</a> <code>curl</code> 命令</h2> <p>发请求，同时接收响应</p> <h2 id="markdown"><a href="#markdown" class="header-anchor">#</a> Markdown</h2> <p>Markdown 不是一个被发明的东西，是被人们总结的语法，所以 MarkDown 的语法形式有很多。</p> <h2 id="www-的发明"><a href="#www-的发明" class="header-anchor">#</a> WWW 的发明</h2> <p>Tim Berners-Lee（下文中称为李爵士）在 1989 年至 1992 年间，发明了 WWW（World Wide Web），一种适用于全世界的网络。主要包含三个概念</p> <ul><li>URI，俗称网址</li> <li>HTTP，两个电脑之间传输内容的协议</li> <li>HTML，超级文本，主要用来做页面跳转</li></ul> <p>URL 的作用是能让你访问一个页面，HTTP 的作用是让你能下载这个页面，HTML 的作用是让你能看懂这个页面。这是一个简单而完美的系统。李爵士除了发明了这些概念，还付诸了行动：</p> <ul><li>发明了第一个服务器</li> <li>发明了第一个浏览器</li> <li>写出了第一个网页，地址：<code>info.cern.ch</code> ，注：网站与网页是不同的，网站是有很多网页的，网页只是一个页面。</li></ul> <h2 id="uri是什么"><a href="#uri是什么" class="header-anchor">#</a> URI是什么</h2> <p>U(统一)R(资源)I(标识符)</p> <p>URI 分为 URL 和 URN 两种</p> <h3 id="urn"><a href="#urn" class="header-anchor">#</a> URN</h3> <p>URN(统一资源名称)</p> <p><code>ISBN: 9787115275790</code> 就是一个 URN，通过 URN 你可以确定一个「唯一的」资源。</p> <p>此处的 <code>ISBN: 9787115275790</code> 对应的资源的是《JavaScript 高级程序设计（第三版）》这本书。基本上你去任何一个图书馆、书店，他们都知道是这本书。</p> <h3 id="url"><a href="#url" class="header-anchor">#</a> URL</h3> <p>URL(统一资源定位符)</p> <img src="/docs/images/the-internet-url.jpg" alt="图片"> <p><code>baidu.com</code> (二级域名) 与  <code>www.baidu.com</code> (三级域名) 共有一个二级域名</p> <p>以 <code>www.baidu.com</code> 为例</p> <ul><li><code>.com</code> 为顶级域名</li> <li><code>baidu</code> 为二级域名</li> <li><code>www</code> 为三级域名</li></ul> <h2 id="dns"><a href="#dns" class="header-anchor">#</a> DNS</h2> <p>D(域)N(名)S(系统): 域名系统</p> <p>功能</p> <ul><li>输入域名</li> <li>输出IP</li></ul> <p>查询域名对应的IP命令</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">nslookup</span> baidu.com
<span class="token function">ping</span> baidu.com
</code></pre></div><p>通过DNS服务器解析域名，得到网址</p> <h3 id="指定ip"><a href="#指定ip" class="header-anchor">#</a> 指定IP</h3> <p>可以给域名一个指定的IP(绕过DNS自己指定一个IP),例:</p> <p>在hosts文件中给百度添加指定域名</p> <div class="language- extra-class"><pre class="language-text"><code>127.0.0.1 baidu.com
</code></pre></div><blockquote><p>特殊情况下，可以通过在 hosts 中给谷歌设置指定IP来达到科学上网的效果(由于设定原因，服务器[电信等网络]可能给你返回一个假的IP)</p> <p>本方法不够稳定，因为谷歌的IP会不定时改变</p></blockquote> <h2 id="server-client-http"><a href="#server-client-http" class="header-anchor">#</a> Server + Client + HTTP</h2> <p>Server(服务器) Client(客户端) HTTP(协议)</p> <p>图示</p> <img src="/docs/images/the-internet-sch.jpg" alt="图片"> <h3 id="常用端口"><a href="#常用端口" class="header-anchor">#</a> 常用端口</h3> <ul><li>21 端口：FTP服务</li> <li>443 端口：HTTPS</li> <li>1080 端口：代理服务器端口</li> <li>3306 端口：MySQI服务器</li> <li>80 端口：HTTP协议</li></ul> <h3 id="http"><a href="#http" class="header-anchor">#</a> HTTP</h3> <p>HTTP的作用就是指导浏览器和服务器如何进行沟通，例如</p> <p>请求的网址错误：返回404</p> <p>请求的服务器不在线(或服务器正在重启)：返回502</p> <h2 id="explainshell-com-网站"><a href="#explainshell-com-网站" class="header-anchor">#</a> explainshell.com 网站</h2> <p>用于解释每个命令的含义</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">curl</span> -s -v -H <span class="token string">&quot;Sun: xxx&quot;</span> -- <span class="token string">&quot;https://www.baidu.com&quot;</span>
</code></pre></div><p><code>-s</code> 不要显示进度条</p> <p><code>-v</code> 显示请求和响应，如果没有这个就只会显示响应</p> <p><code>-H &quot;Sun: xxx&quot;</code> 添加一个响应头</p> <p><code>-- &quot;https://www.baidu.com&quot;</code> 把你要请求的网址写在两个横线后</p> <h2 id="请求"><a href="#请求" class="header-anchor">#</a> 请求</h2> <p>命令</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">curl</span> -s -v -H <span class="token string">&quot;Sun: xxx&quot;</span> -- <span class="token string">&quot;https://www.baidu.com&quot;</span>
</code></pre></div><p>请求案例：</p> <img src="/docs/images/the-internet-curl.jpg" alt="图片"> <p>其中 <code>&gt;</code> 后的内容是请求的内容 <code>&lt;</code> 后的内容是响应的内容 <code>*</code> 后的内容是注释，可不看</p> <p>请求内容中</p> <div class="language- extra-class"><pre class="language-text"><code>GET / HTTP/1.1
GET 请求方式
/ 请求路径
HTTP　请求协议
1.1 版本号

Host: www.baidu.com
告诉服务器我访问的域名

User-Agent: curl/7.64.0
请求/响应使用的工具(软件)以及版本

Accept: */*
表示接收请求返回的任何内容
</code></pre></div><h3 id="post请求"><a href="#post请求" class="header-anchor">#</a> POST请求</h3> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">curl</span> -X POST -s -v -H <span class="token string">&quot;Sun: xxx&quot;</span> -- <span class="token string">&quot;https://www.baidu.com&quot;</span>
</code></pre></div><p>请求案例：</p> <p>其中 <code>-X POST</code> 表示请求方式为POST</p> <p>POST请求传值</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">curl</span> -X POST -d <span class="token string">&quot;123456789&quot;</span> -s -v -H <span class="token string">&quot;Sun: xxx&quot;</span> -- <span class="token string">&quot;https://www.baidu.com&quot;</span>
</code></pre></div><p>请求案例：</p> <p>其中</p> <div class="language- extra-class"><pre class="language-text"><code>Content-Length: 9
请求传入的内容长度
Content-Type: application/x-www-form-urlencoded
请求的类型
# upload completely sent off: 9 out of 9 bytes
完整的上传了9个字节的数据
</code></pre></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">上次更新：</span><span class="time">2021-02-14 20:21</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"><svg aria-hidden="true" class="icon"><use xlink:href="#icon-left"></use></svg> <a href="/docs/devbook/note/search-skill.html" class="prev">搜索引擎常用技巧</a></span> <span class="next"><a href="/docs/devbook/setting/node-use.html">Node.js 安装教程</a> <svg aria-hidden="true" class="icon"><use xlink:href="#icon-right"></use></svg></span></p></div> </main></div><div class="global-ui"><!----><!----></div></div>
    <script src="/docs/assets/js/app.cdec4db9.js" defer></script><script src="/docs/assets/js/2.993bd611.js" defer></script><script src="/docs/assets/js/32.2dad91d1.js" defer></script><script src="/docs/assets/js/7.5a12abef.js" defer></script>
  </body>
</html>
